package com.wans.easyuibackend.exception.handler;

import com.wans.easyuibackend.exception.data.ExcelFormatException;
import com.wans.easyuibackend.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
@Slf4j
public class ExcelFormatExceptionHandler {

    @ExceptionHandler(value = ExcelFormatException.class)
    public ResponseEntity<Result> dataFormatException(ExcelFormatException e) {
        e.printStackTrace();
        log.error(e.getErrorMsg().toString());

        return ResponseEntity.status(Integer.parseInt("400")).body(new Result(400, e.getMessage(), e.getErrorMsg().toString()));
    }
}
